package com.senmin.aPrinciple.a1SingleResponsibilityPrinciple.tdemo1;

/**
 * @className: SingleResponsibility1
 * @author: xpj
 * @create: 2021/6/16
 * @description: 单一职责反例
 */
public class SingleResponsibility2 {
    public static void main(String[] args) {
        RoadVehicle  vehicle = new  RoadVehicle();
        vehicle.run("摩托车");
        vehicle.run("汽车");

        AriVehicle  arivehicle = new  AriVehicle();
        arivehicle.run("飞机");


    }

    //方案二：
    //1.是遵守了单一原则
    //2.但是这样做，花销或者说改动很大，即要将这个类分解多个类，客户端调用也要改动。
    //3.改进方案：直接修改Vehicle类，改动的代码也比较小
    //路上跑的交通工具类
    static class RoadVehicle {
        public void run (String vehicle){
            System.out.println(vehicle + "在公路上运行！");
        }
    }

    //天上飞的交通工具类
    static class AriVehicle {
        public void run (String vehicle){
            System.out.println(vehicle + "在天空上运行！");
        }
    }

    //水中的交通工具类
    static class WaterVehicle {
        public void run (String vehicle){
            System.out.println(vehicle + "在水上上运行！");
        }
    }
}
